/***********************************************************************************
@file  
@author 
@brief  
***********************************************************************************/
#ifndef _MID_LCD_H
#define _MID_LCD_H
/* Private includes ----------------------------------------------------------*/
#include "main.h"
/* Private define ------------------------------------------------------------*/

#define PW33         1
#define PW50         2

#define LCD_MAX_DATA       19999  
#define NO_PARA            (255) //用于不添加switch状态
#define PARA               (0)  
#define lcd_no_flicker()   do{lcd_obj.flicker_cnt=50;}while(0)//改变数字位时，禁止闪烁
#define lcd_flicker()      do{lcd_obj.flicker_cnt=0;lcd_obj.flicker_flag=0;}while(0)//左右移数字位，开始闪烁


#define LCDSEG_A 0x10   
#define LCDSEG_B 0x20
#define LCDSEG_C 0x40
#define LCDSEG_D 0x80
#define LCDSEG_E 0x04
#define LCDSEG_F 0x01
#define LCDSEG_G 0x02

//---------------------ADDR1->RAM4  ADDR2->RAM1
#define LCD_ADDR1_A (0x01<<8)    //RAM4
#define LCD_ADDR1_B (0x02<<8)    //RAM4
#define LCD_ADDR1_C (0x04<<8)    //RAM4
#define LCD_ADDR1_D (0x08<<8)    //RAM4

#define LCD_ADDR1_E (0x04<<16)   //RAM4
#define LCD_ADDR1_F (0x01<<16)   //RAM4
#define LCD_ADDR1_G (0x02<<16)   //RAM4

#define LCD_ADDR2_A (0x01<<8)    //RAM1
#define LCD_ADDR2_B (0x02<<8)    //RAM1
#define LCD_ADDR2_C (0x04<<8)    //RAM1
#define LCD_ADDR2_D (0x08<<8)    //RAM1

#define LCD_ADDR2_E (0x04<<16)   //RAM1
#define LCD_ADDR2_F (0x01<<16)   //RAM1
#define LCD_ADDR2_G (0x02<<16)   //RAM1

#define LCD_ADDR3_A (0x01<<24)   //RAM0
#define LCD_ADDR3_B (0x01<<25)   //RAM0
#define LCD_ADDR3_C (0x01<<26)   //RAM0
#define LCD_ADDR3_D (0x01<<27)   //RAM0

#define LCD_ADDR3_E (0x04<<0)   //RAM1
#define LCD_ADDR3_F (0x01<<0)   //RAM1
#define LCD_ADDR3_G (0x02<<0)   //RAM1

#define CHAR_0   LCDSEG_A+LCDSEG_B+LCDSEG_C+LCDSEG_D+LCDSEG_E+LCDSEG_F
#define CHAR_1   LCDSEG_B+LCDSEG_C
#define CHAR_2   LCDSEG_A+LCDSEG_B+LCDSEG_D+LCDSEG_E+LCDSEG_G
#define CHAR_3   LCDSEG_A+LCDSEG_B+LCDSEG_C+LCDSEG_D+LCDSEG_G
#define CHAR_4   LCDSEG_B+LCDSEG_C+LCDSEG_F+LCDSEG_G
#define CHAR_5   LCDSEG_A+LCDSEG_C+LCDSEG_D+LCDSEG_F+LCDSEG_G
#define CHAR_6   LCDSEG_A+LCDSEG_C+LCDSEG_D+LCDSEG_E+LCDSEG_F+LCDSEG_G
#define CHAR_7   LCDSEG_A+LCDSEG_B+LCDSEG_C
#define CHAR_8   LCDSEG_A+LCDSEG_B+LCDSEG_C+LCDSEG_D+LCDSEG_E+LCDSEG_F+LCDSEG_G
#define CHAR_9   LCDSEG_A+LCDSEG_B+LCDSEG_C+LCDSEG_D+LCDSEG_F+LCDSEG_G

#define CHAR_A   LCDSEG_A+LCDSEG_B+LCDSEG_C+LCDSEG_E+LCDSEG_F+LCDSEG_G
#define CHAR_b   LCDSEG_C+LCDSEG_D+LCDSEG_E+LCDSEG_F+LCDSEG_G
#define CHAR_C   LCDSEG_A+LCDSEG_D+LCDSEG_E+LCDSEG_F
#define CHAR_d   LCDSEG_B+LCDSEG_C+LCDSEG_D+LCDSEG_E+LCDSEG_G
#define CHAR_E   LCDSEG_A+LCDSEG_D+LCDSEG_E+LCDSEG_F+LCDSEG_G
#define CHAR_F   LCDSEG_A+LCDSEG_E+LCDSEG_F+LCDSEG_G
#define CHAR_S   LCDSEG_A+LCDSEG_C+LCDSEG_D+LCDSEG_F+LCDSEG_G
#define CHAR_U   LCDSEG_B+LCDSEG_C+LCDSEG_D+LCDSEG_E+LCDSEG_F
#define CHAR_L   LCDSEG_D+LCDSEG_E+LCDSEG_F
#define CHAR_G   LCDSEG_A+LCDSEG_B+LCDSEG_C+LCDSEG_D+LCDSEG_F+LCDSEG_G
#define CHAR_O   LCDSEG_C+LCDSEG_D+LCDSEG_E+LCDSEG_G
#define CHAR_N   LCDSEG_C+LCDSEG_E+LCDSEG_G


#define ADDR1_CHAR0   LCD_ADDR1_A+LCD_ADDR1_B+LCD_ADDR1_C+LCD_ADDR1_D+LCD_ADDR1_E+LCD_ADDR1_F
#define ADDR1_CHAR1   LCD_ADDR1_B+LCD_ADDR1_C
#define ADDR1_CHAR2   LCD_ADDR1_A+LCD_ADDR1_B+LCD_ADDR1_D+LCD_ADDR1_E+LCD_ADDR1_G
#define ADDR1_CHAR3   LCD_ADDR1_A+LCD_ADDR1_B+LCD_ADDR1_C+LCD_ADDR1_D+LCD_ADDR1_G
#define ADDR1_CHAR4   LCD_ADDR1_B+LCD_ADDR1_C+LCD_ADDR1_F+LCD_ADDR1_G
#define ADDR1_CHAR5   LCD_ADDR1_A+LCD_ADDR1_C+LCD_ADDR1_D+LCD_ADDR1_F+LCD_ADDR1_G
#define ADDR1_CHAR6   LCD_ADDR1_A+LCD_ADDR1_C+LCD_ADDR1_D+LCD_ADDR1_E+LCD_ADDR1_F+LCD_ADDR1_G
#define ADDR1_CHAR7   LCD_ADDR1_A+LCD_ADDR1_B+LCD_ADDR1_C
#define ADDR1_CHAR8   LCD_ADDR1_A+LCD_ADDR1_B+LCD_ADDR1_C+LCD_ADDR1_D+LCD_ADDR1_E+LCD_ADDR1_F+LCD_ADDR1_G
#define ADDR1_CHAR9   LCD_ADDR1_A+LCD_ADDR1_B+LCD_ADDR1_C+LCD_ADDR1_D+LCD_ADDR1_F+LCD_ADDR1_G


#define LCD_RUN   (0x08<<0)   //运行 RAM5
#define LCD_L_RP  (0x08<<16)  //低报 RAM5

#define LCD_DP1   (0x08<<0)    // RAM6
#define LCD_DP2   (0x08<<16)   // RAM6

#define LCD_ADDR_DP1   (0x08<<0)    // RAM1
#define LCD_ADDR_DP2   (0x08<<16)   // RAM1

#define LCD_TEMP  (0x01<<0)   //摄氏度图标 RAM0
#define LCD_TEST  (0x01<<1)   //测试 RAM0
#define LCD_FAULT (0x01<<2)   //故障 RAM0
#define LCD_H_RP  (0x01<<3)   //高报 RAM0

#define LCD_VOL   (0x01<<8)   //%VOL RAM0
#define LCD_LEL   (0x01<<9)   //%LEL RAM0
#define LCD_PPM   (0x01<<10)  //PPM  RAM0
#define LCD_RH    (0x01<<11)  //%RH  RAM0

#define LCD_KUA   (0x01<<16)  //跨度 RAM0
#define LCD_ZERO  (0x01<<17)  //校零 RAM0
#define LCD_CAL   (0x01<<18)  //标定 RAM0
#define LCD_RANGE (0x01<<19)  //量程 RAM0

#define LCD_ADDR  (0x01<<19)  //地址 RAM4
#define LCD_DAT4  (0x0F<<24)  //万位 RAM4


#define LCD_TEST0    (0x01<<24)  //地址后 RAM0
/* Private typedef -----------------------------------------------------------*/
typedef struct{
    
    uint32_t unit;
    uint32_t state;
    uint8_t  flicker_flag;
    uint8_t  flicker_cnt;
}_lcd_obj;
 
extern _lcd_obj lcd_obj;
/* Private variables ---------------------------------------------------------*/
/* Private function ----------------------------------------------------------*/
extern void lcd_init(uint8_t pw);
extern void lcd_dis_result(uint8_t res);
extern void lcd_dis_err(uint8_t err,uint16_t addr);
extern void lcd_dis_num2(uint16_t addr,  uint8_t  data);
extern void lcd_dis_num4(uint8_t  data_f,uint16_t data);
extern void lcd_password_flicker_timer(void);
extern void lcd_set_uint(uint8_t data_f,uint16_t data,uint8_t adr_flag);
extern void lcd_set_dot(char dot1);
extern void lcd_dis_host( uint8_t data_f,uint32_t  data,uint16_t  addr);
extern void lcd_dis_switch(uint8_t res);
extern void lcd_dis_ver(uint32_t data,uint16_t  addr);


extern void lcd_dis_main(  uint32_t   data,\
                           uint8_t    dot1,\
                           uint8_t    sta,\
                           uint8_t    unit,\
                           uint8_t    par,\
                           uint8_t    addr_flag,\
                           uint8_t    addr_flag1,\
                           uint16_t   addr);

extern void lcd_set_data(  uint8_t    data_cnt,\
                           uint8_t    data_f,\
                           uint32_t   data,\
                           uint8_t    dot1,\
                           uint8_t    sta,\
                           uint8_t    unit,\
                           uint8_t    par);

#endif

/**************************** (C) COPYRIGHT CX*****END OF FILE**********************/

